package com.example.networklab.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

@Getter
public enum TaskStatus {
    NOT_START(0, "未开始"),
    IN_PROGRESS(1, "正在进行"),
    END(2, "已结束");

    @JsonValue
    @EnumValue
    private final int code;
    private final String description;

    TaskStatus(int code, String description) {
        this.code = code;
        this.description = description;
    }

    // 根据 code 获取 UserRole
    public static TaskStatus fromCode(int code) {
        for (TaskStatus role : TaskStatus.values()) {
            if (role.getCode() == code) {
                return role;
            }
        }
        throw new IllegalArgumentException("无效的角色代码: " + code);
    }
}

